// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env:"cloud1-9gi73u0tdf91dfdb"})

exports.main = async (event, context) => {
  if(event.select==0){
  cloud.database().collection("user_Info").where({openid:event.openid}).get().then(
    res=>{
     cloud.database().collection("user_Info").doc(res.data[0]['_id']).update({
        data:{
            campus:event.campus,
            gender:event.gender,
            grade:event.grade,
            hobby:event.hobby,
          },    
          success(res){
            return res
          },
          fail(err){
            return err
          }
        })
    }).catch(err=>{console.log(err)})
  }
}